package com.posti.ciudaddelbache.web.ajax;

import com.posti.ciudaddelbache.external.service.interfaces.GeocoderService;
import com.posti.ciudaddelbache.web.dto.GeocodingResultDTO;

//TODO: Evaluar la posibilidad de usar proxies dinamicos
public class GeocoderAjaxService {
  private GeocoderService geocoderService;

  /**
   * @param geocoderService
   */
  public GeocoderAjaxService(GeocoderService geocoderService) {
    this.geocoderService = geocoderService;
  }

  /**
   * @param street
   * @param number
   * @return
   * @see com.posti.ciudaddelbache.external.service.interfaces.GeocoderService#geocodeByAddress(java.lang.String, java.lang.String)
   */
  public GeocodingResultDTO geocodeByAddress(String street, String number) {
    //TODO: Evitar usar esto. Ver la forma de hacer proxies dinamicos.
    return new GeocodingResultDTO(geocoderService.geocodeByAddress(street, number));
  }

  /**
   * @param location
   * @return
   * @see com.posti.ciudaddelbache.external.service.interfaces.GeocoderService#geocodeByLocation(java.lang.String)
   */
  public GeocodingResultDTO geocodeByLocation(String location) {
    return new GeocodingResultDTO(geocoderService.geocodeByLocation(location));
  }

  /**
   * @param id
   * @param street
   * @param number
   * @return
   * @see com.posti.ciudaddelbache.external.service.interfaces.GeocoderService#geocodeByUniqueAddres(java.lang.Long, java.lang.String, java.lang.String)
   */
  public GeocodingResultDTO geocodeByUniqueAddres(Long id, String street, String number) {
    return new GeocodingResultDTO(geocoderService.geocodeByUniqueAddres(id, street, number));
  }
}
